<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/ztree.css">
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--ZTree开始-->
<link rel="stylesheet" href="{$NOW_THEME_URL}/Assets/Plugins/ZTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<include file="treeMenu" />
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Plugins/ZTree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Plugins/ZTree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Plugins/ZTree/js/jquery.ztree.exhide-3.5.js"></script>
<!--ztree结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
	.table_box {
	}
</style>
</head>

<body>
<div class="table_tool">
	<ul class="clearfix">			
		<li class="openwin btn" etitle="新增菜品分类" eheight="350px" ewidth="600px" ehref="{:U('Product/sortAdd')}" id="Product_sortAdd"><i class="icon-plus"></i> 新增菜品分类</li>
	</ul>
</div>
<div class="caipinfenlei clearfix">
		<div class="caipinfenlei_left">
			<form action="{:U('Product/sort')}" method="post" id="from_ele">
			<input type="hidden" name="rname" id="rname" value="" />
				<select name="restid" id="restSel">
					<option value=""><eq name="outletname" value="">请选择餐厅<else />{$outletname}</eq></option>
					<volist name="rest" id="vo">
						<option value="{$vo.id}" >{$vo.title}({$vo.entitle|stripslashes=###})</option>
					</volist>
				</select>
			</form>
			<ul id="treeDemo" class="ztree" style="height:370px;"></ul>
		</div>
		<div class="caipinfenlei_right">
			<div class="tb_title">基本信息</div>
			<form action="{:U('Product/sort')}" method="post" id="form_edit" >
				<input type="hidden" id="id" name="id"  value="{$detail.id}" />
				<table border="0" cellpadding="0" cellspacing="0" class="module_form" >
					<tr>
						<td class="restid" restid="{$outlet.id}">餐厅名称：</td>
						<td><eq name="outlet.id" value="">您还没有选择餐厅<else />{$outlet.title}（{$outlet.entitle|stripslashes=###}）</eq></td>
					</tr>
					<tr>
						<td>分类中文名称：</td>
						<td>
							<input name="title" value="{$detail.title}" id="title" type="text" class="form_ele_text width_200">
							<eq name="detail.id" value=""><else /><a class="form_ele_clearOne">点击删除该分类</a></eq>
						</td>
					</tr>
					<tr>
						<td>分类英文名称：</td>
						<td><input name="entitle" value="{$detail.entitle}" id="entitle" type="text" class="form_ele_text width_200"></td>
					</tr>
					<tr>
						<td>排序号：</td>
						<td><input name="sort" value="{$detail.sort}" id="sort" type="text" class="form_ele_text width_200"></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div class="page_footer pdtd10">
		<input type="button" name="submit" value="提  交"  class="form_ele_submit"/>
		<input type="reset"  name="reset"  value="取  消"  class="form_ele_reset"/>
	</div>
	
<script type="text/javascript">
//弹出窗口全局变量
var api = frameElement.api, W = api.opener;

$(function(){
	
	//重置
	$('.form_ele_reset').on('click',function(){
		frameApi.close(); //关闭当前窗口
	});
	
	
	$("#restSel>option").each(function(){

		$(this).on("click",function(){
			$("#rname").val($(this).html());
			$("#from_ele").submit();
		});
		
	});
	
	//删除
	$(".form_ele_clearOne").on("click",function(){
		var id = $("#id").val();
		if(id){
			$.get("{:U('Product/sortDel')}",{id:id},function(){
				
				windowApi.lhgdialog.alert('删除成功！');
				var obj = windowApi.lhgdialog.list['Product_sort'];
				//obj.reload(obj);
			});
		}else{
			windowApi.lhgdialog.alert('请选择类别！');
		}
		
	});
	
	//提交
	$('.form_ele_submit').on('click',function(){
		
		var postData = {};
		
		postData   = $("#form_edit").serialize();
		var id     = $("#id").val();
		var restid = $(".restid").attr("restid");
		if(restid){
			if(id){
				$.post("{:U('Product/sortEdit')}",postData,function(d){
					if(d.status==1){
						windowApi.lhgdialog.alert('类别修改成功！');
					   	window.location.href = "{:U('Product/sort')}&restid="+restid+"&id="+id;
					}else{
						windowApi.lhgdialog.alert('类别修改失败！');
					}
				});
			}else{
				windowApi.lhgdialog.alert('请先在左上角点击选择餐厅菜品分类！');return false;
			}
		}else{
			windowApi.lhgdialog.alert('请先在左上角选择餐厅！');return false;
		}
		
	});
	
});
</script>
</html>
